home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 07 DecisionMaking Architectures / 01 Isla, Blumberg / LocatableMission.java < prev    next >
Encoding:
Java Source  |  2001-09-25  |  1.2 KB  |  49 lines

  1. package bb;
  2.  
  3. import java.util.*;
  4.  
  5. /*
  6. A special subclass of missions that also has an associated location.
  7. It also has a "range" argument which indicates how close the 
  8. agents should get to the target position.
  9.  
  10. @author naimad
  11. */
  12.  
  13. public class LocatableMission extends Mission {
  14.  
  15.     Vec2 targetPos;
  16.     double range = 15.0;    //optional range. How close should we get?
  17.  
  18.     public LocatableMission(String skillname, int number, double priority, Vec2 targetPos) {
  19.         super(skillname, number, priority);
  20.         this.targetPos = new Vec2(targetPos);
  21.     }
  22.  
  23.     public LocatableMission(String skillname, int number, double priority, Vec2 targetPos, double range) {
  24.         this(skillname, number, priority, targetPos);
  25.         this.range = range;
  26.     }
  27.  
  28.     public void setTargetPosition(Vec2 newpos) {
  29.         targetPos.set(newpos);
  30.     }
  31.  
  32.     public void getTargetPosition(Vec2 inplace) {
  33.         inplace.set(targetPos);
  34.     }
  35.  
  36.     public void setRange(double range) {
  37.         this.range = range;
  38.     }
  39.     
  40.     public double getRange() {
  41.         return range;
  42.     }
  43.     
  44.     public String toString() {
  45.         return super.toString() + " at " + targetPos;   
  46.     }
  47.     
  48. }
  49.